package system.data;

import java.util.*;

import framework.core.*;

/*
 Author    :Wing
 CreateTime:2008-03-04 14:47:09
 */
public class WarehouseCustomerBase extends Table {
    public static final String TABLE_NAME = "T_WAREHOUSE_CUSTOMER";

    private static final String BACKUP_TABLE_NAME = "T_WAREHOUSE_CUSTOMER_BACKUP";

    private static final String BACKUP_SEQ_NAME = "S_WAREHOUSE_CUSTOMER_BACKUP";

    public static final String ID = "ID";

    public static final String WAREHOUSE_CODE = "WAREHOUSE_CODE";

    public static final String CUSTOMER_CODE = "CUSTOMER_CODE";

    public static final String CREATE_USER_ID = "CREATE_USER_ID";

    public static final String CREATE_USER = "CREATE_USER";

    public static final String CREATE_TIME = "CREATE_TIME";

    public static final String LAST_UPDATE_USER_ID = "LAST_UPDATE_USER_ID";

    public static final String LAST_UPDATE_USER = "LAST_UPDATE_USER";

    public static final String LAST_UPDATE_TIME = "LAST_UPDATE_TIME";

    public static final String STATUS = "STATUS";

    public static Vector m_fields = null;

    private String m_id = ""; // ID

    private String m_warehouse_code = ""; // WAREHOUSE_CODE

    private String m_customer_code = ""; // CUSTOMER_CODE

    private String m_create_user_id = ""; // CREATE_USER_ID

    private String m_create_user = ""; // CREATE_USER

    private String m_create_time = ""; // CREATE_TIME

    private String m_last_update_user_id = ""; // LAST_UPDATE_USER_ID

    private String m_last_update_user = ""; // LAST_UPDATE_USER

    private String m_last_update_time = ""; // LAST_UPDATE_TIME

    private String m_status = ""; // 是否有效

    public String getId() {
        return m_id;
    }

    public void setId(String v) {
        if (getId().equals(v))
            return;
        m_id = v;
        markDirty(ID);
    }

    public String getWarehouseCode() {
        return m_warehouse_code;
    }

    public void setWarehouseCode(String v) {
        if (getWarehouseCode().equals(v))
            return;
        m_warehouse_code = v;
        markDirty(WAREHOUSE_CODE);
    }

    public String getCustomerCode() {
        return m_customer_code;
    }

    public void setCustomerCode(String v) {
        if (getCustomerCode().equals(v))
            return;
        m_customer_code = v;
        markDirty(CUSTOMER_CODE);
    }

    public String getCreateUserId() {
        return m_create_user_id;
    }

    public void setCreateUserId(String v) {
        if (getCreateUserId().equals(v))
            return;
        m_create_user_id = v;
        markDirty(CREATE_USER_ID);
    }

    public String getCreateUser() {
        return m_create_user;
    }

    public void setCreateUser(String v) {
        if (getCreateUser().equals(v))
            return;
        m_create_user = v;
        markDirty(CREATE_USER);
    }

    public String getCreateTime() {
        return m_create_time;
    }

    public void setCreateTime(String v) {
        if (getCreateTime().equals(v))
            return;
        m_create_time = v;
        markDirty(CREATE_TIME);
    }

    public String getLastUpdateUserId() {
        return m_last_update_user_id;
    }

    public void setLastUpdateUserId(String v) {
        if (getLastUpdateUserId().equals(v))
            return;
        m_last_update_user_id = v;
        markDirty(LAST_UPDATE_USER_ID);
    }

    public String getLastUpdateUser() {
        return m_last_update_user;
    }

    public void setLastUpdateUser(String v) {
        if (getLastUpdateUser().equals(v))
            return;
        m_last_update_user = v;
        markDirty(LAST_UPDATE_USER);
    }

    public String getLastUpdateTime() {
        return m_last_update_time;
    }

    public void setLastUpdateTime(String v) {
        if (getLastUpdateTime().equals(v))
            return;
        m_last_update_time = v;
        markDirty(LAST_UPDATE_TIME);
    }

    public String getStatus() {
        return m_status;
    }

    public void setStatus(String v) {
        if (getStatus().equals(v))
            return;
        m_status = v;
        markDirty(STATUS);
    }    
    
    public String viewId(DBConnection con) throws Exception {
        return Value.view(getId());
    }

    public String viewWarehouseCode(DBConnection con) throws Exception {
        return Value.view(getWarehouseCode());
    }

    public String viewCustomerCode(DBConnection con) throws Exception {
        return Value.view(getCustomerCode());
    }

    public String viewCreateUserId(DBConnection con) throws Exception {
        return Value.view(getCreateUserId());
    }

    public String viewCreateUser(DBConnection con) throws Exception {
        return Value.view(getCreateUser());
    }

    public String viewCreateTime(DBConnection con) throws Exception {
        return Value.view(getCreateTime());
    }

    public String viewLastUpdateUserId(DBConnection con) throws Exception {
        return Value.view(getLastUpdateUserId());
    }

    public String viewLastUpdateUser(DBConnection con) throws Exception {
        return Value.view(getLastUpdateUser());
    }

    public String viewLastUpdateTime(DBConnection con) throws Exception {
        return Value.view(getLastUpdateTime());
    }
    
    public String viewStatus(DBConnection con) throws Exception {
        return Value.view(getStatus());
    }    

    protected WarehouseCustomerBase() {
    }

    public void fill(WarehouseCustomerPageData pageData) throws Exception {

        if (pageData.getId() != null) {
            setId(pageData.getId());
        }

        if (pageData.getWarehouseCode() != null) {
            setWarehouseCode(pageData.getWarehouseCode());
        }

        if (pageData.getCustomerCode() != null) {
            setCustomerCode(pageData.getCustomerCode());
        }

        if (pageData.getCreateUserId() != null) {
            setCreateUserId(pageData.getCreateUserId());
        }

        if (pageData.getCreateUser() != null) {
            setCreateUser(pageData.getCreateUser());
        }

        if (pageData.getCreateTime() != null) {
            setCreateTime(pageData.getCreateTime());
        }

        if (pageData.getLastUpdateUserId() != null) {
            setLastUpdateUserId(pageData.getLastUpdateUserId());
        }

        if (pageData.getLastUpdateUser() != null) {
            setLastUpdateUser(pageData.getLastUpdateUser());
        }

        if (pageData.getLastUpdateTime() != null) {
            setLastUpdateTime(pageData.getLastUpdateTime());
        }
        
        if (pageData.getStatus() != null) {
            setStatus(pageData.getStatus());
        }

    }

    public String getTableName() {
        return TABLE_NAME;
    }

    public String getBackupTableName() {
        return BACKUP_TABLE_NAME;
    }

    public String getBackupSeqName() {
        return BACKUP_SEQ_NAME;
    }

    public java.util.Vector getFields() {
        if (m_fields == null) {
            m_fields = new Vector();

            m_fields.add(new Field(ID, Value.TYPE_STRING, true, true, 32, "ID"));

            m_fields.add(new Field(WAREHOUSE_CODE, Value.TYPE_STRING, false, true, 20, "WAREHOUSE_CODE"));

            m_fields.add(new Field(CUSTOMER_CODE, Value.TYPE_STRING, false, true, 20, "CUSTOMER_CODE"));

            m_fields.add(new Field(CREATE_USER_ID, Value.TYPE_STRING, false, true, 32, "CREATE_USER_ID"));

            m_fields.add(new Field(CREATE_USER, Value.TYPE_STRING, false, true, 50, "CREATE_USER"));

            m_fields.add(new Field(CREATE_TIME, Value.TYPE_STRING, false, true, 20, "CREATE_TIME"));

            m_fields.add(new Field(LAST_UPDATE_USER_ID, Value.TYPE_STRING, false, true, 32, "LAST_UPDATE_USER_ID"));

            m_fields.add(new Field(LAST_UPDATE_USER, Value.TYPE_STRING, false, true, 50, "LAST_UPDATE_USER"));

            m_fields.add(new Field(LAST_UPDATE_TIME, Value.TYPE_STRING, false, true, 20, "LAST_UPDATE_TIME"));

            m_fields.add(new Field(STATUS, Value.TYPE_STRING, false, true, 1, "是否有效"));
        }
        return m_fields;
    }

    public void initObject(java.sql.ResultSet rs) throws Exception {

        m_id = getString(rs, ID);

        m_warehouse_code = getString(rs, WAREHOUSE_CODE);

        m_customer_code = getString(rs, CUSTOMER_CODE);

        m_create_user_id = getString(rs, CREATE_USER_ID);

        m_create_user = getString(rs, CREATE_USER);

        m_create_time = getString(rs, CREATE_TIME);

        m_last_update_user_id = getString(rs, LAST_UPDATE_USER_ID);

        m_last_update_user = getString(rs, LAST_UPDATE_USER);

        m_last_update_time = getString(rs, LAST_UPDATE_TIME);
        
        m_status = getString(rs, STATUS);

        ms_new_flag = ConstDefine.NO;
    }

    public Value get(String f) {

        if (f.equalsIgnoreCase(ID)) {
            return new Value(getId());
        }

        if (f.equalsIgnoreCase(WAREHOUSE_CODE)) {
            return new Value(getWarehouseCode());
        }

        if (f.equalsIgnoreCase(CUSTOMER_CODE)) {
            return new Value(getCustomerCode());
        }

        if (f.equalsIgnoreCase(CREATE_USER_ID)) {
            return new Value(getCreateUserId());
        }

        if (f.equalsIgnoreCase(CREATE_USER)) {
            return new Value(getCreateUser());
        }

        if (f.equalsIgnoreCase(CREATE_TIME)) {
            return new Value(getCreateTime());
        }

        if (f.equalsIgnoreCase(LAST_UPDATE_USER_ID)) {
            return new Value(getLastUpdateUserId());
        }

        if (f.equalsIgnoreCase(LAST_UPDATE_USER)) {
            return new Value(getLastUpdateUser());
        }

        if (f.equalsIgnoreCase(LAST_UPDATE_TIME)) {
            return new Value(getLastUpdateTime());
        }
        
        if (f.equalsIgnoreCase(STATUS)) {
            return new Value(getStatus());
        }

        return null;
    }

    public void set(String f, Value v) throws Exception {

        if (f.equalsIgnoreCase(ID)) {
            setId(v.getString());
        }

        if (f.equalsIgnoreCase(WAREHOUSE_CODE)) {
            setWarehouseCode(v.getString());
        }

        if (f.equalsIgnoreCase(CUSTOMER_CODE)) {
            setCustomerCode(v.getString());
        }

        if (f.equalsIgnoreCase(CREATE_USER_ID)) {
            setCreateUserId(v.getString());
        }

        if (f.equalsIgnoreCase(CREATE_USER)) {
            setCreateUser(v.getString());
        }

        if (f.equalsIgnoreCase(CREATE_TIME)) {
            setCreateTime(v.getString());
        }

        if (f.equalsIgnoreCase(LAST_UPDATE_USER_ID)) {
            setLastUpdateUserId(v.getString());
        }

        if (f.equalsIgnoreCase(LAST_UPDATE_USER)) {
            setLastUpdateUser(v.getString());
        }

        if (f.equalsIgnoreCase(LAST_UPDATE_TIME)) {
            setLastUpdateTime(v.getString());
        }
        
        if (f.equalsIgnoreCase(STATUS)) {
            setStatus(v.getString());
        }

    }

    public String toString() {
        String msg = "WarehouseCustomer=\n";
        msg += "(\r\n";

        msg += "    ID(id)=" + get("id") + "\r\n";

        msg += "    WAREHOUSE_CODE(warehouse_code)=" + get("warehouse_code") + "\r\n";

        msg += "    CUSTOMER_CODE(customer_code)=" + get("customer_code") + "\r\n";

        msg += "    CREATE_USER_ID(create_user_id)=" + get("create_user_id") + "\r\n";

        msg += "    CREATE_USER(create_user)=" + get("create_user") + "\r\n";

        msg += "    CREATE_TIME(create_time)=" + get("create_time") + "\r\n";

        msg += "    LAST_UPDATE_USER_ID(last_update_user_id)=" + get("last_update_user_id") + "\r\n";

        msg += "    LAST_UPDATE_USER(last_update_user)=" + get("last_update_user") + "\r\n";

        msg += "    LAST_UPDATE_TIME(last_update_time)=" + get("last_update_time") + "\r\n";
        
        msg += "    STATUS(status)=" + get("status") + "\r\n";

        msg += ")\r\n";
        return msg;
    }

    public void copyBase(WarehouseCustomerBase srcObj) {

        setId(srcObj.getId());

        setWarehouseCode(srcObj.getWarehouseCode());

        setCustomerCode(srcObj.getCustomerCode());

        setCreateUserId(srcObj.getCreateUserId());

        setCreateUser(srcObj.getCreateUser());

        setCreateTime(srcObj.getCreateTime());

        setLastUpdateUserId(srcObj.getLastUpdateUserId());

        setLastUpdateUser(srcObj.getLastUpdateUser());

        setLastUpdateTime(srcObj.getLastUpdateTime());
        
        setStatus(srcObj.getStatus());

    }

    public String toXml() throws Exception {
        String xml = "";
        xml += "<WarehouseCustomer>";

        xml += "<Id>" + Value.view(getId()) + "</Id>";

        xml += "<WarehouseCode>" + Value.view(getWarehouseCode()) + "</WarehouseCode>";

        xml += "<CustomerCode>" + Value.view(getCustomerCode()) + "</CustomerCode>";

        xml += "<CreateUserId>" + Value.view(getCreateUserId()) + "</CreateUserId>";

        xml += "<CreateUser>" + Value.view(getCreateUser()) + "</CreateUser>";

        xml += "<CreateTime>" + Value.view(getCreateTime()) + "</CreateTime>";

        xml += "<LastUpdateUserId>" + Value.view(getLastUpdateUserId()) + "</LastUpdateUserId>";

        xml += "<LastUpdateUser>" + Value.view(getLastUpdateUser()) + "</LastUpdateUser>";

        xml += "<LastUpdateTime>" + Value.view(getLastUpdateTime()) + "</LastUpdateTime>";
        
        xml += "<Status>" + Value.view(getStatus()) + "</Status>";

        xml += "</WarehouseCustomer>";
        return xml;
    }

}
